<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.global.js"></script>
</head>

<body>
    <div id="app">
        <div id="event-with-method">
            <!-- `greet` 是在下面定义的方法名 -->
            <button @click="greet">Greet</button>
        </div>
        <hr>
        <div id="inline-handler">
            <button @click="say('hi')">Say hi</button>
            <button @click="say('what',$event)">Say what</button>
        </div>
        <hr>

        <!-- 这两个 one() 和 two() 将执行按钮点击事件 -->
        <button @click="greet($event), say('fuckoff',$event)">
            Submit
        </button>
        
    </div>

    <script>
        const app = {
            data() {
                return {
                    name: 'Vue.js'
                }
            },
            methods: {
                greet(event) {
                    // `methods` 内部的 `this` 指向当前活动实例
                    alert('Hello ' + this.name + '!')
                    // `event` 是原生 DOM event
                    console.log("event", event);
                    if (event) {
                        alert(event.target.tagName)//BUTTON
                    }
                },
                say(message, e) {
                    console.log("e=", e);
                    alert(message)
                }
            }
        }
        Vue.createApp(app).mount("#app")
    </script>
</body>

</html>